﻿using Basic.WxRemoteModel.WxMsg.Model;
using Basic.WxService.ConstDic;
using Basic.WxService.Interface;
using WeDonekRpc.Client.Attr;
using WeDonekRpc.Client.Interface;

namespace Basic.WxService.WxMsg
{
    [ClassLifetimeAttr(ClassLifetimeType.SingleInstance)]
    internal class PlatformEventService : IPlatformEventService
    {
        private readonly IIocService _Ioc;

        public PlatformEventService (IIocService ioc)
        {
            this._Ioc = ioc;
        }

        public void EventMsg (WxPlatformMsg msg)
        {
            if (WxPlatformEventDic.Check(msg.EventType))
            {
                IWxPlatformMsgEvent msgEvent = this._Ioc.Resolve<IWxPlatformMsgEvent>(msg.EventType);
                msgEvent.ExecMsg(msg);
            }
        }
    }
}
